SUCCESS = 200
FAILED = 300
ERROR = 500


class Msg:

    def __init__(self, code, data):
        self._code = code
        self._data = data

    def is_success(self) -> bool:
        return self._code == 200

    def get_data(self):
        return self._data

    @staticmethod
    def error(err: Exception):
        return Msg(ERROR, data=str(err))

    @staticmethod
    def success(data):
        return Msg(SUCCESS, data=data)

    @staticmethod
    def failed(msg):
        return Msg(FAILED, data=msg)
